#include "mystring.h"
#include <stdio.h>
#include <stdlib.h>

int main()
{
    // 测试 mystrdup
    char *s1 = mystrdup("Hello, C!");
    printf("mystrdup: %s\n", s1);
    free(s1); // 记得释放！

    // 测试 mystrcat
    char buffer[20] = "Hello";
    mystrcat(buffer, ", World!", sizeof(buffer));
    printf("mystrcat: %s\n", buffer);

    // 测试 mystrsplit
    char **parts = NULL;
    int count = mystrsplit("one,two,three", ',', &parts);
    printf("mystrsplit (%d parts):\n", count);
    for (int i = 0; i < count; i++)
    {
        printf("  [%d] %s\n", i, parts[i]);
    }
    mystrsplit_free(parts, count); // 释放分割结果

    return 0;
}